  
  //定义Trie类
   var Trie = function() {
    this.children = {};
   };
  
   //插入实现
   Trie.prototype.insert = function(word) {
    let node = this.children;
       for (const ch of word) {
           if (!node[ch]) {
               node[ch] = {};
           }
           node = node[ch];
       }
       node.isEnd = true;
   };

   Trie.prototype.searchPrefix = function(prefix) {
    let node = this.children;
    for (const ch of prefix) {
        if (!node[ch]) {
            return false;
        }
        node = node[ch];
    }
    return node;
}

 //检索单词是否存在
  Trie.prototype.search = function(word) {
    const node = this.searchPrefix(word);
     return node !== undefined && node.isEnd !== undefined;
   };
 
  //检索单词是否已经是之前插入的单词的前缀
  Trie.prototype.startsWith = function(prefix) {
    return this.searchPrefix(prefix);
    };

apple,appoint

 let data =    {a:
                    {p:
                        {p:
                            {l:
                                {e:
                                    {
                                        isEnd:true 
                                    }
                                },
                                o:{
                                    i:{
                                        n:{
                                            t:{
                                                isEnd:true
                                              }
                                          }
                                      } 
                                  }      
                            }, 
                            
                        }
                    }
                }
   